package com.cm.service.impl;

import com.cm.mapper.DeptMapper;
import com.cm.pojo.Dept;
import com.cm.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * ClassName:  DeptServiceImpl
 * Package: com.cm.service.impl
 * Description:
 *
 * @Author:
 * @Create: 2025/7/12  2:42
 * @Version 1.0
 */
@Service
public class DeptServiceImpl implements DeptService {
@Autowired
private DeptMapper deptMapper;

    @Override
    public void delete(Integer id) {
        deptMapper.delete(id);
        System.out.println("删除成功"+ id);
    }

    @Override
     public void add(Dept dept) {
        //补全属性
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.add(dept);

    }

    @Override
    public void update(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.update(dept);
    }

    @Override
    public Dept searchById(Integer id) {

        return deptMapper.searchByid(id);
    }

    @Override
    public List<Dept> findall() {
    return deptMapper.findAll();

    }
}
